;; 详细的call/cc if测试，添加了完整的调试输出

(define x '(1 2 3))
(define k-if #f)

(display "原始x的值: ")
(display x)
(display "\n\n")

(display "开始执行if表达式...\n")
(define initial-result
  (if (call/cc
        (lambda(k)
          (display "在call/cc的lambda中，设置continuation到k-if\n")
          (set! k-if k)
          (display "计算条件表达式 (null? x)，结果为: ")
          (display (null? x))
          (display "\n")
          (null? x)))
      (begin
        (display "条件为真，执行then分支: '()\n")
        '())
      (begin
        (display "条件为假，执行else分支: (cdr x) = ")
        (display (cdr x))
        (display "\n")
        (cdr x))))

(display "\ninitial-result的值: ")
(display initial-result)
(display "\n\n")

(display "调用(k-if #t)...\n")
(define result-t (k-if #t))
(display "result-t的值: ")
(display result-t)
(display "\n\n")

(display "调用(k-if #f)...\n")
(define result-f (k-if #f))
(display "result-f的值: ")
(display result-f)
(display "\n")